import 'package:flutter/material.dart';
import 'package:ytbusiness/config/style.dart';
import 'package:ytbusiness/utils/helper.dart';
import 'package:ytbusiness/widgets/widgets.dart';

class OrderPage extends StatefulWidget {
  //{type}
  final Map<String, dynamic> arguments;

  const OrderPage({Key key, this.arguments}) : super(key: key);

  @override
  _OrderPageState createState() => _OrderPageState();
}

class _OrderPageState extends State<OrderPage> {
  String title = "";

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: YTStyle.bgColor,
      appBar: customAppBar(context, title: widget.arguments["title"] as String),
      body: SafeArea(
        child: ListView.builder(
            shrinkWrap: true,
            itemCount: 10,
            itemBuilder: (context, index) {
              return GestureDetector(
                onTap: () {
                  _orderState(widget.arguments["type"] as String);
                },
                child: listItem(
                  title: "[安徽-合肥] 云途养护旗舰店",
                  state: widget.arguments["title"] as String,
                  orderNum: "AE998820031",
                  accessories: "奥迪A3配件(共13件)",
                  havePrice: "共10个产品，已报价3个",
                  time: "2020-11-23 14:02",
                ),
              );
            }),
      ),
    );
  }

  //订单状态
  _orderState(String type) {
    switch (type) {

      ///待报价
      case "0":
        urlPush(context, "yuntu://waiting_offer");
        break;

      ///已报价
      case "1":
        urlPush(context, "yuntu://have_price");
        break;

      ///等待付款
      case "2":
        urlPush(context, "yuntu://auto_await_pay");
        break;

      ///待发货
      case "3":
        urlPush(context, "yuntu://waiting_delivery");
        break;

      ///已发货
      case "4":
        urlPush(context, "yuntu://already_deliver");
        break;

      ///待回票
      case "5":
        urlPush(context, "yuntu://await_ticket");
        break;

      ///已开票
      case "6":
        urlPush(context, "yuntu://make_ticket");
        break;

      ///已退票
      case "7":
        urlPush(context, "yuntu://refund_ticket");
        break;

      ///待结算
      case "8":
        urlPush(context, "yuntu://await_settlement");
        break;

      ///已结算
      case "9":
        urlPush(context, "yuntu://have_settlement");
        break;

      ///已取消
      case "10":
        urlPush(context, "yuntu://canceled");
        break;

      ///退款中
      case "11":
        urlPush(context, "yuntu://refund");
        break;

      ///已退款
      case "12":
        urlPush(context, "yuntu://refunded");
        break;
    }
  }
}
